//
//  ViewController.m
//  JKRRegularDemo
//
//  Created by 陈星妤 on 16/6/7.
//  Copyright © 2016年 陈星妤. All rights reserved.
//

#import "ViewController.h"
#import "NSString+Regex.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    NSString *str = @"yanbing.hu@icloud.com";
    
    if ([str isEmail]) {
        NSLog(@"是邮箱");
    } else {
        NSLog(@"不是邮箱");
    }
    
}



+ (BOOL) validateEmail:(NSString *)email
{
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    return [emailTest evaluateWithObject:email];
}

@end
